<!---
 @Name: index.vue
 @Author: lhf
 @Owner:
 @Date: 2025-07-15 15:20:27
 @LastEditTime: 2025-07-15 15:20:27
 @LastEditors:lhf
 @Description:  医院信息
 @Version:
 @FilePath: src\views\column\index.vue
--->

<template>
  <div :class="['container', mode]" v-show="show" :key="`${mode}-${show}`">
    <div v-if="mode === 'column'" ref="conRef" class="column-body" v-html="content"></div>
    <div v-else-if="mode === 'docInfo'" class="doc-section flex-body">
      <div class="doc-left">
        <div class="doc-avator flex-center">
          <img :src="content.workingPicture || ''" alt="" @error="avatarError" />
        </div>
        <div class="doc-info">
          <h3 class="txt-ellipsis">{{ content.doctorName || '' }}</h3>
          <div class="doc-title">
            <span class="txt-ellipsis">{{ content.doctorTitleName || '' }}</span>
          </div>
          <div class="doc-dept txt-ellipsis">{{ content.deptName || '' }}</div>
        </div>
      </div>
      <div class="doc-right">
        <div class="doc-body" v-html="content.intro || ''" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'BeseColumn',
  props: {
    mode: {
      type: String,
      default: 'column'
    }
  },
  components: {},
  data() {
    return {};
  },
  computed: {
    show() {
      return this.$store.state.show;
    },
    content() {
      if (this.show) {
        const str = this.$store.state.info || '';
        const info = JSON.parse(str);
        return info.content;
      }
      return '';
    }
  },
  mounted() {
    this.$nextTick(() => {
      const conRef = this.$refs.conRef;
      if (conRef) {
        conRef.addEventListener('click', (e) => {
          if (e.target.tagName === 'IMG') {
            const url = e.target.getAttribute('src');
            if (url) this.$AndroidSdk.ImageAction(url);
          }
          if (e.target.classList.contains('edui-box')) {
            const url = e.target.getAttribute('src');
            if (url) {
              const obj = {
                x: 0,
                y: 0,
                width: document.body.clientWidth,
                height: document.body.clientHeight,
                url: url
              };
              this.$AndroidSdk.PlayVideoAction(JSON.stringify(obj));
            }
          }
        });
      }
    });
  },
  methods: {
    avatarError(e) {
      e.target.src = require('@/assets/images/avator.png');
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.container {
  height: 100%;
  background: #f2f6fc;
  border-radius: 20px;
  padding: 30px;
  position: absolute;
  width: 100%;
  top: 0;
  .column-body {
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch; /* iOS 惯性滚动 */
    scroll-behavior: smooth; /* 平滑滚动 */
    line-height: 2;
    text-align: justify;
    word-break: break-word;
    font-size: 32px;
    :deep(p) {
      text-indent: 2em;
    }
    :deep(img) {
      width: 85%;
      margin: 0 auto;
      display: block;
      object-fit: contain;
    }
    :deep(.edui-box) {
      width: 800px;
      height: 400px;
      background: url('@/assets/images/bg-video.png') no-repeat center;
      background-size: cover;
      margin: 0 auto;
      video {
        visibility: hidden;
        display: block;
      }
    }
  }
  &.docInfo {
    padding: 0;
    background: transparent;
    .doc-section {
      height: 100%;
      overflow: auto;
      -webkit-overflow-scrolling: touch; /* iOS 惯性滚动 */
      scroll-behavior: smooth; /* 平滑滚动 */
      line-height: 2;
      text-align: justify;
      word-break: break-word;
      font-size: 32px;
      .doc-left {
        width: 460px;
        background: #fff;
        border-radius: 20px;
        border: 2px solid #ddd;
        padding: 30px;
        .doc-avator {
          width: 400px;
          height: 543px;
          overflow: hidden;
          border-radius: 20px;
          img {
            display: block;
            object-fit: contain;
            width: 400px;
          }
        }
        .doc-info {
          text-align: center;
          overflow: hidden;
          h3 {
            height: 120px;
            font-weight: 500;
            font-size: 60px;
            color: #333;
            line-height: 120px;
          }
          .doc-title {
            height: 50px;
            line-height: 50px;
            font-weight: 500;
            font-size: 30px;
            color: #fff;
            span {
              background: #0059b3;
              border-radius: 10px;
              display: inline-block;
              vertical-align: top;
              padding: 0 10px;
              max-width: 100%;
            }
          }
          .doc-dept {
            height: 120px;
            font-weight: 500;
            font-size: 42px;
            color: #0059b3;
            line-height: 120px;
          }
        }
      }
      .doc-right {
        flex: 1;
        margin-left: 30px;
        overflow: hidden;
        background: #fff;
        border-radius: 20px;
        padding: 30px 50px;
        .doc-body {
          overflow: auto;
          -webkit-overflow-scrolling: touch; /* iOS 惯性滚动 */
          scroll-behavior: smooth; /* 平滑滚动 */
          height: 100%;
        }
      }
    }
  }
}
</style>
